﻿
namespace SeedObject
{
    /// <summary>
    /// Lets work with lists allowing set operations
    /// </summary>
    public static class Conjunct
    {
        #region AllEqualTo
        /// <summary>
        /// query if all elements of the set are equal to observed element
        /// </summary>
        /// <typeparam name="T">DBType of object</typeparam>
        /// <param name="observed">observed element</param>
        /// <param name="List">Sets</param>
        /// <returns>ActionResult of operation</returns>
        public static bool AllEqualTo<T>(T observed, System.Collections.Generic.IList<T> list)
        {
            // validates the contents 
            if (list == null) return false;
            for (int i = 0; i < list.Count; i++)
                if (!list[i].Equals(observed))
                    return false;
            return true;
        }
        #endregion

        #region SomeLikeA
        /// <summary>
        /// query if some element is equal to
        /// </summary>
        /// <typeparam name="T">DBType of the object</typeparam>
        /// <param name="observed">observed element</param>
        /// <param name="lists">Sets</param>
        /// <returns>ActionResult of operation</returns>
         public static bool SomeLikeA<T>(T observed, System.Collections.Generic.IList<T> lists)
        {
            // valida el contenido del conjunto
            if (lists == null) return false;
            for (int i = 0; i < lists.Count; i++)
                if (lists[i].Equals(observed))
                    return true;
            return false;
        }
        #endregion
    }
}
